from datd_define import Record


# 先定义一个抽象类做顶层设计
class FileRead:

    def read_data(self) -> list[Record]:
        pass


# 定义一个子类，继承抽象类，并实现抽象方法
class FileReadImpl(FileRead):
    def __init__(self, path):
        self.path = path



    def read_data(self) -> list[Record]:
        f = open(self.path, 'r', encoding='utf-8')
        record_list: list[Record] = []
        for line in f.readlines():
            line = line.strip()
            data_list = line.split(",")
            record = Record(data_list[0], data_list[1], int(data_list[2]), data_list[3])
            record_list.append(record)
        f.close()
        return record_list
if __name__ == '__main__':
    file = FileReadImpl("你.txt")
    records = file.read_data()
